using UnityEngine;
using System.Collections;

[System.Serializable]
public class ZoomCamera : MonoBehaviour {
	
	/**
	 * http://answers.unity3d.com/questions/20693/camera-zoom-in-script.html
	 * Adapted to C# by André Nilsen
	 * 08. October 2012
	 * */
	
	int zoom = 20;
	int normal = 60;
	float smooth = 5f;
	
	public bool isZoomed = false;
	public Camera cameraToZoom;
	 
	void Update () {
		if(Input.GetKeyDown("z")){
		     isZoomed = !isZoomed; 
		}
			 if(isZoomed == true){
		     cameraToZoom.fieldOfView = Mathf.Lerp(cameraToZoom.fieldOfView,zoom,Time.deltaTime*smooth);
		}
		else {
		   cameraToZoom.fieldOfView = Mathf.Lerp(cameraToZoom.fieldOfView,normal,Time.deltaTime*smooth);
		}
	}
}
